/**
 * Copyright (c) 2019 xstgongyi.org
 * All rights reserved.
 */
package org.xstgongyi.eduaid.controller;

import org.xstgongyi.eduaid.dataobject.SponsorDO;
import org.xstgongyi.eduaid.dataobject.StudentAidDO;
import org.xstgongyi.eduaid.dataobject.StudentDO;
import org.xstgongyi.eduaid.dataobject.VolunteerDO;
import org.xstgongyi.eduaid.bo.DonateStatus;
import org.xstgongyi.eduaid.bo.FundStatus;
import org.xstgongyi.eduaid.bo.Gender;
import org.xstgongyi.eduaid.bo.SponsorFeedbackStatus;
import org.xstgongyi.eduaid.bo.StudentAidStatus;
import org.xstgongyi.eduaid.bo.StudentAidType;
import org.xstgongyi.eduaid.bo.StudentFeedbackStatus;
import org.xstgongyi.eduaid.bo.StudentPairStatus;
import org.xstgongyi.eduaid.dataobject.GradeDO;
import org.xstgongyi.eduaid.dataobject.ProjectDO;
import org.xstgongyi.eduaid.dataobject.SemesterDO;

/**
 * @author oldcrane<br/>
 * @created 2019-04-24
 */
public class StudentAidDTO {

	private Integer id;
	private Integer studentId;
	private String studentName;
	private String studentGender;
	private String studentSn;

	private Integer projectId;
	private String projectName;
	private Integer semesterId;
	private String semesterName;

	private String school;
	private Integer gradeId;
	private String gradeName;

	private StudentAidStatus aidStatus;
	private String aidStatusName;
	private Integer aidAmount;
	private StudentAidType aidType;
	private String aidTypeName;
	private StudentPairStatus pairStatus;
	private String pairStatusName;
	private Integer sponsorId;
	private String sponsorName;

	private FundStatus fundStatus;
	private String fundStatusName;
	private DonateStatus donateStatus;
	private String donateStatusName;
	private StudentFeedbackStatus receiptStatus;
	private String receiptStatusName;
	private StudentFeedbackStatus summaryStatus;
	private String summaryStatusName;
	private SponsorFeedbackStatus receiptFeedbackStatus;
	private String receiptFeedbackStatusName;
	private SponsorFeedbackStatus summaryFeedbackStatus;
	private String summaryFeedbackStatusName;
	private String remark;

	private Integer volunteerId;
	private String volunteerName;

	public static StudentAidDTO of(StudentAidDO aid) {
		StudentAidDTO vo = new StudentAidDTO();
		vo.id = aid.getId();
		vo.studentId = aid.getStudentId();
		vo.sponsorId = aid.getSponsorId();
		vo.volunteerId = aid.getVolunteerId();

		vo.aidAmount = aid.getAidAmount();
		vo.school = aid.getSchool();
		vo.remark = aid.getRemark();

		vo.aidStatus = aid.getAidStatus();
		vo.aidStatusName = (null == vo.aidStatus ? "" : vo.aidStatus.getLabel());
		vo.aidType = aid.getAidType();
		vo.aidTypeName = (null == vo.aidType ? "" : vo.aidType.getLabel());
		vo.pairStatus = aid.getPairStatus();
		vo.pairStatusName = (null == vo.pairStatus ? "" : vo.pairStatus.getLabel());
		vo.fundStatus = aid.getFundStatus();
		vo.fundStatusName = (null == vo.fundStatus ? "" : vo.fundStatus.getLabel());
		vo.donateStatus = aid.getDonateStatus();
		vo.donateStatusName = (null == vo.donateStatus ? "" : vo.donateStatus.getLabel());

		vo.receiptStatus = aid.getReceiptStatus();
		vo.receiptStatusName = (null == vo.receiptStatus ? "" : vo.receiptStatus.getLabel());
		vo.summaryStatus = aid.getSummaryStatus();
		vo.summaryStatusName = (null == vo.summaryStatus ? "" : vo.summaryStatus.getLabel());
		vo.receiptFeedbackStatus = aid.getReceiptFeedbackStatus();
		vo.receiptFeedbackStatusName = (null == vo.receiptFeedbackStatus ? "" : vo.receiptFeedbackStatus.getLabel());
		vo.summaryFeedbackStatus = aid.getSummaryFeedbackStatus();
		vo.summaryFeedbackStatusName = (null == vo.summaryFeedbackStatus ? "" : vo.summaryFeedbackStatus.getLabel());

		return vo;
	}

	public void setStudentInfo(StudentDO student) {
		if (null != student) {
			this.studentId = student.getId();
			this.studentName = student.getName();
			this.studentGender = (null == student.getGender() ? Gender.unknown.getLabel()
					: student.getGender().getLabel());
			this.studentSn = student.getSn();
		}
	}

	public void setSponsorInfo(SponsorDO sponsor) {
		if (null != sponsor) {
			this.sponsorId = sponsor.getId();
			this.sponsorName = sponsor.getName();
			if (null != sponsor.getNickname() && sponsor.getNickname().length() > 0) {
				this.sponsorName += "(" + sponsor.getNickname() + ")";
			}
		}
	}

	public void setVolunteerInfo(VolunteerDO volunteer) {
		if (null != volunteer) {
			this.volunteerId = volunteer.getId();
			this.volunteerName = volunteer.getName();
		}
	}

	public void setProjectInfo(ProjectDO project) {
		if (null != project) {
			this.projectId = project.getId();
			this.projectName = project.getName();
		}
	}

	public void setSemesterInfo(SemesterDO semester) {
		if (null != semester) {
			this.semesterId = semester.getId();
			this.semesterName = semester.getName();
		}
	}

	public void setGradeInfo(GradeDO grade) {
		if (null != grade) {
			this.gradeId = grade.getId();
			this.gradeName = grade.getName();
		}
	}

	public StudentAidDO toStudentAidDO() {
		StudentAidDO aidDO = new StudentAidDO();

		aidDO.setStudentId(this.getStudentId());
		aidDO.setProjectId(this.getProjectId());
		aidDO.setSemesterId(this.getSemesterId());
		aidDO.setSchool(this.getSchool());
		aidDO.setGradeId(this.getGradeId());
		aidDO.setRemark(this.getRemark());
		aidDO.setVolunteerId(this.getVolunteerId());

		aidDO.setAidAmount(null == getAidAmount() ? 0 : getAidAmount());
		aidDO.setAidStatus(null == getAidStatus() ? StudentAidStatus.approved : getAidStatus());
		aidDO.setAidType(null == getAidType() ? StudentAidType.unknwon : getAidType());

		aidDO.setPairStatus(null == getPairStatus() ? StudentPairStatus.waitPair : getPairStatus());
		aidDO.setSponsorId(this.getSponsorId());

		aidDO.setFundStatus(null == getFundStatus() ? FundStatus.waitTransfer : getFundStatus());
		aidDO.setReceiptStatus(null == getReceiptStatus() ? StudentFeedbackStatus.waitFeedback : getReceiptStatus());
		aidDO.setReceiptFeedbackStatus(
				null == getReceiptFeedbackStatus() ? SponsorFeedbackStatus.todo : getReceiptFeedbackStatus());
		aidDO.setSummaryStatus(null == getSummaryStatus() ? StudentFeedbackStatus.waitFeedback : getSummaryStatus());
		aidDO.setSummaryFeedbackStatus(
				null == getSummaryFeedbackStatus() ? SponsorFeedbackStatus.todo : getSummaryFeedbackStatus());

		return aidDO;
	}

	// getter/setter

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getStudentId() {
		return studentId;
	}

	public void setStudentId(Integer studentId) {
		this.studentId = studentId;
	}

	public String getStudentName() {
		return studentName;
	}

	public void setStudentName(String studentName) {
		this.studentName = studentName;
	}

	public String getStudentGender() {
		return studentGender;
	}

	public void setStudentGender(String studentGender) {
		this.studentGender = studentGender;
	}

	public String getStudentSn() {
		return studentSn;
	}

	public void setStudentSn(String studentSn) {
		this.studentSn = studentSn;
	}

	public Integer getProjectId() {
		return projectId;
	}

	public void setProjectId(Integer projectId) {
		this.projectId = projectId;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public Integer getSemesterId() {
		return semesterId;
	}

	public void setSemesterId(Integer semesterId) {
		this.semesterId = semesterId;
	}

	public String getSemesterName() {
		return semesterName;
	}

	public void setSemesterName(String semesterName) {
		this.semesterName = semesterName;
	}

	public String getSchool() {
		return school;
	}

	public void setSchool(String school) {
		this.school = school;
	}

	public Integer getGradeId() {
		return gradeId;
	}

	public void setGradeId(Integer gradeId) {
		this.gradeId = gradeId;
	}

	public String getGradeName() {
		return gradeName;
	}

	public void setGradeName(String gradeName) {
		this.gradeName = gradeName;
	}

	public StudentAidStatus getAidStatus() {
		return aidStatus;
	}

	public void setAidStatus(StudentAidStatus aidStatus) {
		this.aidStatus = aidStatus;
	}

	public String getAidStatusName() {
		return aidStatusName;
	}

	public void setAidStatusName(String aidStatusName) {
		this.aidStatusName = aidStatusName;
	}

	public Integer getAidAmount() {
		return aidAmount;
	}

	public void setAidAmount(Integer aidAmount) {
		this.aidAmount = aidAmount;
	}

	public StudentAidType getAidType() {
		return aidType;
	}

	public void setAidType(StudentAidType aidType) {
		this.aidType = aidType;
	}

	public String getAidTypeName() {
		return aidTypeName;
	}

	public void setAidTypeName(String aidTypeName) {
		this.aidTypeName = aidTypeName;
	}

	public StudentPairStatus getPairStatus() {
		return pairStatus;
	}

	public void setPairStatus(StudentPairStatus pairStatus) {
		this.pairStatus = pairStatus;
	}

	public String getPairStatusName() {
		return pairStatusName;
	}

	public void setPairStatusName(String pairStatusName) {
		this.pairStatusName = pairStatusName;
	}

	public Integer getSponsorId() {
		return sponsorId;
	}

	public void setSponsorId(Integer sponsorId) {
		this.sponsorId = sponsorId;
	}

	public String getSponsorName() {
		return sponsorName;
	}

	public void setSponsorName(String sponsorName) {
		this.sponsorName = sponsorName;
	}

	public FundStatus getFundStatus() {
		return fundStatus;
	}

	public void setFundStatus(FundStatus fundStatus) {
		this.fundStatus = fundStatus;
	}

	public String getFundStatusName() {
		return fundStatusName;
	}

	public void setFundStatusName(String fundStatusName) {
		this.fundStatusName = fundStatusName;
	}

	public DonateStatus getDonateStatus() {
		return donateStatus;
	}

	public void setDonateStatus(DonateStatus donateStatus) {
		this.donateStatus = donateStatus;
	}

	public String getDonateStatusName() {
		return donateStatusName;
	}

	public void setDonateStatusName(String donateStatusName) {
		this.donateStatusName = donateStatusName;
	}

	public StudentFeedbackStatus getReceiptStatus() {
		return receiptStatus;
	}

	public void setReceiptStatus(StudentFeedbackStatus receiptStatus) {
		this.receiptStatus = receiptStatus;
	}

	public String getReceiptStatusName() {
		return receiptStatusName;
	}

	public void setReceiptStatusName(String receiptStatusName) {
		this.receiptStatusName = receiptStatusName;
	}

	public StudentFeedbackStatus getSummaryStatus() {
		return summaryStatus;
	}

	public void setSummaryStatus(StudentFeedbackStatus summaryStatus) {
		this.summaryStatus = summaryStatus;
	}

	public String getSummaryStatusName() {
		return summaryStatusName;
	}

	public void setSummaryStatusName(String summaryStatusName) {
		this.summaryStatusName = summaryStatusName;
	}

	public SponsorFeedbackStatus getReceiptFeedbackStatus() {
		return receiptFeedbackStatus;
	}

	public void setReceiptFeedbackStatus(SponsorFeedbackStatus receiptFeedbackStatus) {
		this.receiptFeedbackStatus = receiptFeedbackStatus;
	}

	public String getReceiptFeedbackStatusName() {
		return receiptFeedbackStatusName;
	}

	public void setReceiptFeedbackStatusName(String receiptFeedbackStatusName) {
		this.receiptFeedbackStatusName = receiptFeedbackStatusName;
	}

	public SponsorFeedbackStatus getSummaryFeedbackStatus() {
		return summaryFeedbackStatus;
	}

	public void setSummaryFeedbackStatus(SponsorFeedbackStatus summaryFeedbackStatus) {
		this.summaryFeedbackStatus = summaryFeedbackStatus;
	}

	public String getSummaryFeedbackStatusName() {
		return summaryFeedbackStatusName;
	}

	public void setSummaryFeedbackStatusName(String summaryFeedbackStatusName) {
		this.summaryFeedbackStatusName = summaryFeedbackStatusName;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Integer getVolunteerId() {
		return volunteerId;
	}

	public void setVolunteerId(Integer volunteerId) {
		this.volunteerId = volunteerId;
	}

	public String getVolunteerName() {
		return volunteerName;
	}

	public void setVolunteerName(String volunteerName) {
		this.volunteerName = volunteerName;
	}

}
